<template>
  <div id="notice">  
  <div  style="display:flex;align-items: center;">
            <img class="top_img" src="@/assets/images/a8.png" style="width:35px;height:35px;margin-right:10px;"/>
            <div style="line-height: 40px;font-weight:bold:">开屏公告</div>
     </div>
  <el-row>
        <el-col :span="24" style="text-align: right;">         
            <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="mtk1_but()">
              <img class="custom_color_button1_img" src="@/assets/images/but_bg2.png" />添加公告
            </el-button>         
        </el-col>
  </el-row>


   <!-- 渲染数据list -->
   <notice-list :datalist="datalist" @up_list_fun="list_fun"> </notice-list>

   <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>
    

    <el-dialog title="添加公告" :visible.sync="mtk1"  width="500px" >
          <el-form ref="form"   label-width="80px" style="width:100%;">

                <el-form-item label="选择日期" >
                 <el-date-picker type="date"  placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="mtk1_form.startdate"  style="width:100%;"></el-date-picker>
               </el-form-item>
               <el-form-item label="结束日期" >
                 <el-date-picker type="date"  placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="mtk1_form.enddate"  style="width:100%;"></el-date-picker>
               </el-form-item>
                <el-form-item label="添加标题">
                    <el-input v-model="mtk1_form.title" placeholder="必填"></el-input>
                </el-form-item> 
                 <el-form-item label="添加内容">
                    <el-input v-model="mtk1_form.content" type="textarea" :rows="4" placeholder="必填"></el-input>
                </el-form-item>

         </el-form>
          <div style="text-align: center;width:70%;margin:auto;">
                  <el-button type="primary" class="custom_color_button" style="width:80%;" @click="mtk1_but_qr()">确认</el-button>
          </div>

   </el-dialog> 
    

      
  </div>
</template>

<script>
import NoticeList from '@/view/Infor/NoticeList'
export default {
  name: 'notice',
  data () {
    return {
        datalist:[],
        page:1,
        count:0,
        mtk1:false,
        mtk1_form:{
            startdate:'',
            enddate:'',
            title:'',
            content:''
        }
    }
  },
 components:{
    NoticeList
  },
  created(){
    this.list_fun()
  },
  mounted (){
    
  },
  methods: {

      list_fun(){
          this.post("/newspaper/listOfOpenScreenData", {
              page:this.page, 
	        }).then(res => {
            this.count = res.result.count
            this.datalist = res.result.list
            console.log(res)
         })
      },
      
      mtk1_but(){
          this.mtk1 = true
      },
      mtk1_but_qr(){
       this.post("/newspaper/addOpenScreen", {
                title:this.mtk1_form.title,
                content:this.mtk1_form.content,
                startdate:this.mtk1_form.startdate,
                enddate:this.mtk1_form.enddate,
            }).then(res => {
                if(res.error_code == 0){
                    this.open1(res.result,'success')  //提示框
                    this.mtk1 = false
                    this.list_fun()
                }else {
                this.open1(res.message,'warning')
                }

       })
     },
     handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.page = val
        this.list_fun()
        console.log(`当前页: ${val}`);
      }
  }
}
</script>


<style scoped>

</style>
